package com.biometric.core.authenticator.impl

import androidx.annotation.Keep
import androidx.biometric.BiometricManager
import androidx.biometric.BiometricPrompt
import androidx.fragment.app.FragmentActivity
import com.wei.android.lib.fingerprintidentify.Authenticator

@Keep
class CredentialAuthenticator(val context: FragmentActivity,val title:String = "please unlock with pattern first") : Authenticator {

    override fun authenticate(authenticateListener: Authenticator.AuthenticateListener) {
        val promptInfo = BiometricPrompt.PromptInfo.Builder()
            .setTitle(title)
            .setAllowedAuthenticators(BiometricManager.Authenticators.DEVICE_CREDENTIAL)
            .build()
        BiometricPrompt(context, object : BiometricPrompt.AuthenticationCallback() {
            override fun onAuthenticationFailed() {
                super.onAuthenticationFailed()

            }
        }).authenticate(promptInfo)
    }

    override fun reAuthenticate() {

    }

    override fun cancelAuthenticate() {

    }

}